home *** CD-ROM | disk | FTP | other *** search
- /*-------------------------------------------------------------------------------------
- *
- * Simple Sample PowerTalk Application Framework
- *
- * ©1991-1993 Apple Computer
- *
- -------------------------------------------------------------------------------------*/
- /*
- * base.window.c -- base class for windows
- *
- * this is the base class for all of the window classes in the framework
- * no windows of this class are actually instantiated, but all window
- * classes are derived from this class
- *
- * change history:
- *
- * SJF 08/23/93 1.0f1 update to final headers, fix comments
- * SJF 04/21/93 1.0b2 update to b2
- * SJF 03/01/93 1.0b1 added digital signatures
- * SJF 02/09/93 1.0b1 update to b1
- * SJF 10/13/92 1.0d4 update to a11
- * SJF 09/09/92 1.0d3 update to a9
- * SJF 05/07/92 1.0d2 update to a6
- * SJF 11/06/91 1.0d1 initial coding
- *
- */
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
- #ifndef __QUICKDRAW__
- #include <QuickDraw.h>
- #endif
-
- #ifndef __WINDOWS__
- #include <Windows.h>
- #endif
-
- #ifndef __MEMORY__
- #include <Memory.h>
- #endif
-
- #ifndef __MENUS__
- #include <Menus.h>
- #endif
-
- #include "const.h"
- #include "strconst.h"
- #include "mytypes.h"
- #include "globals.h"
- #include "utils.h"
- #include "windowstuff.h"
-
- #include "base.window.h"
-
-
- /* instantiate a new base window */
-
- WindowPtr BaseMakeWindow(Rect *wRect,StringPtr title,Boolean visible,short wdefProc,
- Boolean goAwayFlag)
- {
- WInfoHndl infoHndl;
- WInfoPtr infoPtr;
- WindowPtr theWindow;
- Str255 defaultTitle;
-
-
- if (title==nil) {
- GetResString(defaultTitle,kDefaultTitleID,kDefaultTitle);
- title = defaultTitle;
- }
-
- infoHndl = NewHandleChk(sizeof(WInfo));
- if (MemError()!=noErr)
- return nil;
-
- MoveHHi((Handle) infoHndl);
- HLock((Handle) infoHndl);
- infoPtr = *infoHndl;
-
- infoPtr->m_idle = BaseIdleWindow;
- infoPtr->m_fixCursor = BaseFixCursorWindow;
- infoPtr->m_activate = BaseActivateWindow;
- infoPtr->m_deactivate = BaseDeactivateWindow;
- infoPtr->m_update = BaseUpdateWindow;
- infoPtr->m_key = BaseKeyWindow;
- infoPtr->m_resize = BaseResizeWindow;
- infoPtr->m_click = BaseClickWindow;
- infoPtr->m_destroy = BaseDestroyWindow;
- infoPtr->m_undo = BaseUndoWindow;
- infoPtr->m_cut = BaseCutWindow;
- infoPtr->m_copy = BaseCopyWindow;
- infoPtr->m_paste = BasePasteWindow;
- infoPtr->m_clear = BaseClearWindow;
- infoPtr->m_print = BasePrintWindow;
- infoPtr->m_pageSetup = BasePageSetupWindow;
- infoPtr->m_save = BaseSaveWindow;
- infoPtr->m_load = BaseLoadWindow;
- infoPtr->m_event = BaseEventWindow;
- infoPtr->m_ctrlHit = BaseHitControlWindow;
- infoPtr->m_selectAll = BaseSelectAllWindow;
- infoPtr->m_group = BaseGroupWindow;
- infoPtr->m_unGroup = BaseUnGroupWindow;
-
- if (HasColorQD())
- theWindow = NewCWindow(nil,wRect,title,visible,wdefProc,(WindowPtr)-1L,goAwayFlag,
- (unsigned long)infoHndl);
- else
- theWindow = NewWindow(nil,wRect,title,visible,wdefProc,(WindowPtr)-1L,goAwayFlag,
- (unsigned long)infoHndl);
-
- SetWindowKind(theWindow,kBaseWindow);
-
- pstrcpy(infoPtr->fileSpec.name,title);
- infoPtr->refCount = gNextWindowToMake++;
- infoPtr->window = theWindow;
- infoPtr->saved = false;
- infoPtr->changed = false;
- infoPtr->fRefNum = 0;
- infoPtr->resRefNum = 0;
- infoPtr->topIndent = 0;
- infoPtr->leftIndent = 0;
-
- infoPtr->printRecord = NewHandleChk(sizeof(TPrint));
- if (MemError()!=noErr)
- return nil;
-
- PrOpen();
- PrintDefault(infoPtr->printRecord);
- if (PrError()!=noErr)
- DoError(PrError());
- PrClose();
-
- return theWindow;
- }
-
-
- /* deallocate any memory associated with the base window class */
-
- void *BaseDestroyWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
- {
- #pragma unused (window,data)
-
- DisposHandleChk(infoPtr->printRecord);
-
- return nil;
- }
-
-
- /* handle null events for base window */
-
- void *BaseIdleWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
- {
- #pragma unused (window,infoPtr,data)
-
- return nil;
- }
-
-
- /* handle mouse-moved events for base window */
-
- void *BaseFixCursorWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
- {
- #pragma unused (window,infoPtr,data)
-
- return nil;
- }
-
-
- /* handle activate events for base window */
-
- void *BaseActivateWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
- {
- #pragma unused (infoPtr,data)
-
- MyDrawGrowIcon(window);
- return nil;
- }
-
-
- /* handle deactivate events for base window */
-
- void *BaseDeactivateWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
- {
- #pragma unused (infoPtr,data)
-
- MyDrawGrowIcon(window);
- SetDefaultMenus();
- gMenusDirty = true;
- return nil;
- }
-
-
- /* handle update events for base window */
-
- void *BaseUpdateWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
- {
- #pragma unused (infoPtr,data)
-
- MyDrawGrowIcon(window);
- return nil;
- }
-
-
- /* handle resize for base window */
-
- void *BaseResizeWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
- {
- #pragma unused (infoPtr,data)
- Rect gbRect;
-
- gbRect = window->portRect;
- gbRect.top = gbRect.bottom - kGrowBoxWidth;
- gbRect.left = gbRect.right - kGrowBoxWidth;
- EraseRect(&gbRect);
-
- return nil;
- }
-
-
- /* handle keypress for base window */
-
- void *BaseKeyWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
- {
- #pragma unused (window,infoPtr,data)
-
- return nil;
- }
-
-
- /* handle mouse click in content for base window */
-
- void *BaseClickWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
- {
- #pragma unused (window,data)
-
- infoPtr->changed = true;
- return nil;
- }
-
-
- /* handle undo for base window */
-
- void *BaseUndoWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
- {
- #pragma unused (window,infoPtr,data)
-
- return nil;
- }
-
-
- /* handle clipboard cut for base window */
-
- void *BaseCutWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
- {
- #pragma unused (window,infoPtr,data)
-
- return nil;
- }
-
-
- /* handle clipboard copy for base window */
-
- void *BaseCopyWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
- {
- #pragma unused (window,infoPtr,data)
-
- return nil;
- }
-
-
- /* handle clipboard paste for base window */
-
- void *BasePasteWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
- {
- #pragma unused (window,infoPtr,data)
-
- return nil;
- }
-
-
- /* handle clipboard clear for base window */
-
- void *BaseClearWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
- {
- #pragma unused (window,infoPtr,data)
-
- return nil;
- }
-
-
- /* handle select all for base window */
-
- void *BaseSelectAllWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
- {
- #pragma unused (window,infoPtr,data)
-
- return nil;
- }
-
-
- /* handle group objects for base window */
-
- void *BaseGroupWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
- {
- #pragma unused (window,infoPtr,data)
-
- return nil;
- }
-
-
- /* handle ungroup objects for base window */
-
- void *BaseUnGroupWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
- {
- #pragma unused (window,infoPtr,data)
-
- return nil;
- }
-
-
- /* handle print for base window */
-
- void *BasePrintWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
- {
- #pragma unused (window,infoPtr,data)
-
- return nil;
- }
-
-
- /* handle page setup for base window */
-
- void *BasePageSetupWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
- {
- #pragma unused (window,data)
-
- infoPtr->changed = true;
-
- return nil;
- }
-
-
- /* handle save document for base window */
-
- void *BaseSaveWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
- {
- #pragma unused (window,data)
-
- infoPtr->saved = true;
- infoPtr->changed = false;
-
- return nil;
- }
-
-
- /* handle load document for base window */
-
- void *BaseLoadWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
- {
- #pragma unused (window,data)
-
- infoPtr->saved = true;
- infoPtr->changed = false;
-
- return nil;
- }
-
-
- /* handle generic event for base window */
-
- void *BaseEventWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
- {
- #pragma unused (window,infoPtr,data)
-
- return nil;
- }
-
-
- /* handle mousedown in control for base window */
-
- void *BaseHitControlWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
- {
- #pragma unused (window,infoPtr,data)
-
- return nil;
- }
-
-